package com.epfresh.supplier.activity.my_contract;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.epfresh.api.entity.RequestEntitySupply;
import com.epfresh.api.entity.ResponseEntity;
import com.epfresh.api.global.BaseActivity;
import com.epfresh.api.global.BaseApplication;
import com.epfresh.api.http.OnRequestListener;
import com.epfresh.supplier.R;
import com.epfresh.supplier.adapter.MyContractRecyclerViewAdapter;
import com.epfresh.supplier.entity.ContractEntity;
import com.epfresh.supplier.entity.TestReport;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyContractDetailActivity extends BaseActivity {
    private static final String TAG="MyContractDetail";
    private TextView tv_contract_name,tv_contract_status,tv_contract_no,
            tv_sign_contract_date,tv_contract_start_date,tv_contract_end_date,tv_download_contract;
    private String contractId;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_contract_detail);
        tvBack.setVisibility(View.VISIBLE);
        ivBack.setVisibility(View.VISIBLE);
        toolbarTitle.setText("我的合同");

        initView();
        initData();
        setListener();

        //加载数据
//        requestTestReportDetail();

    }




    private void initView() {
        tv_contract_name=findViewById(R.id.tv_contract_name);
        tv_contract_status=findViewById(R.id.tv_contract_status);
        tv_contract_no=findViewById(R.id.tv_contract_no);
        tv_sign_contract_date=findViewById(R.id.tv_sign_contract_date);
        tv_contract_start_date=findViewById(R.id.tv_contract_start_date);
        tv_contract_end_date=findViewById(R.id.tv_contract_end_date);
        tv_download_contract=findViewById(R.id.tv_download_contract);

    }

    private void setListener() {
        //下载合同
        tv_download_contract.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    private void initData() {
        contractId=getIntent().getStringExtra("");
        Log.e(TAG,"获取的合同id="+contractId);



    }



    /**
     * 加载合同列表数据
     */
    private void requestTestReportDetail() {
        RequestEntitySupply<Map<String, String>> data = new RequestEntitySupply<>();
        data.setCmd(com.epfresh.api.constant.AppSupplyRouterConstant.cmd_order_supplier_order_incomeProductIncomeForDayOfMonth);
        Map<String, String> map = new HashMap<>();
        map.put("storeId", BaseApplication.getInstance().getStoreId());

        map.put("accountId",getUser().getAccountId());
        data.setParameters(map);
        request(data, com.epfresh.api.constant.AppSupplyRouterConstant.cmd_order_supplier_order_incomeProductIncomeForDayOfMonth, onRequestListener);
    }

    private OnRequestListener<TestReport> onRequestListener = new OnRequestListener<TestReport>() {
        @Override
        public TestReport jsonToObj(String responseStr) {
            return new Gson().fromJson(responseStr, TestReport.class);
        }

        @Override
        public void onFail(int failCode, Object arg, Object tag) {
            hideProgressDialog();
            finish();
        }

        @Override
        public void onResponseError(int failCode, Object arg, Object tag) {
            hideProgressDialog();
            finish();
        }

        @Override
        public void onStart(Object tag) {
            showProgressDialog();
        }

        @Override
        public void onResponse(ResponseEntity<TestReport> response, Object tag) {
            //隐藏加载动画
            hideProgressDialog();
            //获取数据
            TestReport responseElement = response.getResponseElement();
            //显示数据
            showInfo();

        }
    };

    private void showInfo() {

    }

}
